package Demo6;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
//字节流
public class FileInputStreamTest1 {
    public static void main(String[] args) throws IOException {
        InputStream is = null;
        try {
            //创建输入流(拉通管道)
            is=new FileInputStream("f:/TEST/hello.txt");
            //读取(流水)
            byte[] b = new byte[1024];
            int len;
            while ((len=is.read(b))!=-1) {
                //把读取到的结果打印出来
                System.out.println(new String(b,1,len));
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
